#ifndef GUIEVENT_H
#define GUIEVENT_H


namespace gui
{

	////////////////////////////////////////////////////////////////////////////////////////////////

	enum GuiEventTypeEnum
    {
		GuiEvent_size,
		GuiEvent_mouse,

		GuiEvent_custom,
	};

	struct GuiEvent
	{
		GuiEventTypeEnum type;

		const GuiEventTypeEnum& getType()const	{return type; }

	protected:
		GuiEvent(const GuiEventTypeEnum& eventtype)
			: type(eventtype)
		{
		}
	};

	////////////////////////////////////////////////////////////////////////////////////////////////

	struct SizeEvent : public GuiEvent
    {
        Vector size;
        Vector oldsize;

        SizeEvent(const Vector& _size, const Vector& _oldsize)
        : GuiEvent(GuiEvent_size), size(_size), oldsize(_oldsize)
        {
        }

        friend std::ostream& operator << (std::ostream& os, const SizeEvent& evt)
        {
            os << "SIZEEVENT: (sz: " << evt.size << "; old: " << evt.oldsize << " )";
            return os;
        }
    };


    ////////////////////////////////////////////////////////////////////////////////////////////////

    enum MouseButtonEnum
    {
        MouseButton_no =        0x000,
        MouseButton_left =      0x001,
        MouseButton_right =     0x010,
        MouseButton_middle =    0x100,
    };
    enum MouseEventTypeEnum
    {
        MouseEvent_other =     0x000,
        MouseEvent_move =      0x001,
        MouseEvent_click =     0x010,
        MouseEvent_release =   0x100,
    };

    struct MouseEvent : public GuiEvent
    {
        Vector pos;
        unsigned int buttonflags;
        unsigned int typeflags;

        MouseEvent(const Vector& mousepos)
        : GuiEvent(GuiEvent_mouse), pos(mousepos), buttonflags(0x0), typeflags(0x0)
        {
        }

        MouseEvent(const Vector& mousepos, const unsigned _buttonflags)
        : GuiEvent(GuiEvent_mouse), pos(mousepos), buttonflags(_buttonflags), typeflags(0x0)
        {
        }

        MouseEvent(const Vector& mousepos, const unsigned _buttonflags, const unsigned _typeflags)
        : GuiEvent(GuiEvent_mouse), pos(mousepos), buttonflags(_buttonflags), typeflags(_typeflags)
        {
        }

        bool isPressed(MouseButtonEnum button) {return ((buttonflags&button)&0x111)!=0; }
        bool isReleased(MouseButtonEnum button) {return !isPressed(button); }
        bool isType(MouseEventTypeEnum type) {return ((typeflags&type)&0x111)!=0; }

        friend std::ostream& operator << (std::ostream& os, const MouseEvent& evt)
        {
            os << "MOUSEEVENT: (pos: " << evt.pos << "; btn: " << evt.buttonflags << "; type: " << evt.typeflags <<  " )";
            return os;
        }


    };

}
#endif // GUIEVENT_H
